package com.scc.utils;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import oracle.jdbc.pool.OracleDataSource;

public class DatabaseManager
{
   private static String connection_url = "jdbc:oracle:thin:IIEV/12345@ioleonov:1521:XE";
    
   public static String getConnection_url()
   {
      return connection_url;
   }

   public static Connection getConnection()
   {
      Connection conn = null;
      try
      {
         OracleDataSource ds = new OracleDataSource();
         //ds.setURL("jdbc:oracle:thin:IIEV/12345@ioleonov:1521:XE");
         ds.setURL(connection_url);
         conn = ds.getConnection();
      }
      catch (SQLException e1)
      {
         e1.printStackTrace();
      }
      return conn;
   }

   public static boolean closeStatement(Statement stm)
   {
      boolean result = true;
      if (stm != null)
      {
         try
         {
            stm.close();
         }
         catch (SQLException e)
         {
            result = false;
         }
      }
      return result;
   }
   
   public static boolean closeConnection(Connection conn)
   {
      boolean result = true;
      if (conn != null)
      {
         try
         {
            conn.close();
         }
         catch (SQLException e)
         {
            result = false;
         }
      }
      return result;
   }
}
